def lengthOfLongestSubstring(s):
    table = {}
    res = 0
    i = 0
    for j in range(len(s)):
        if s[j] in table:
            i = max(table[s[j]], i)
        res = max(res, j - i + 1)
        table[s[j]] = j + 1
    return res


s = "abcabccdd"
print(lengthOfLongestSubstring(s))
